#include "lcd.h"
#include "touch.h"

int main(void)
{
    lcd_init();
    
    // 设置背景色
    lcd_draw_rect(0, 0, 800, 480, WHITE);

    enum Color buf[4] = {RED, GREEN, BLUE, YELLOW};
    int index = 0;

    while (1) {
        // 获取触摸屏的坐标
        int x, y;
        touch_wait(&x, &y);

        if(x > 0 && x<400)
        {
            printf("left\n");
            index = (index-1)< 0 ? 3 : index-1;
        }
        else if(x >=400 && x<800)
        {
            printf("right\n");
            index = (index+1) % 4;
        }

        lcd_draw_rect(200, 120, 200, 120, buf[index]);
    }
}